All Questions
9 questions
4votes
1answer
117views
Calculate optimal game upgrades, v2
This is the second iteration of the code I originally posted here: Calculate optimal game upgrades. Based on the feedback there, I chose to change the code to use a dynamic programming approach with ...
3votes
2answers
364views
Divide a set into subset with some constraints
Problem: Given a list L consisting of not necessarily unique non-negative integers, find the minimum number of subset with maximum sum ...
7votes
1answer
1kviews
Printing the number of ways a message can be decoded
My below solution to the following problem is exceeding the maximum recursion depth. I am looking for any improvements which i can make. Problem Alice and Bob need to send secret messages to each ...
5votes
1answer
351views
Total number of non overlapping subsets
I am trying to solve this question. The essence of the problem is this: Given a list of school classes with start and end times, find the total number of non-overlapping subsets. I've written up a ...
4votes
1answer
633views
The Dungeon game
This is a Leetcode problem - The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our ...
2votes
0answers
377views
Bursting Balloons
This is a Leetcode problem - Given n balloons, indexed from 0 to n-1. Each balloon is ...
-1votes
1answer
908views
Python program to solve the "rod-cutting problem"
An assignment at school required me to write a program for this task: In the rod-cutting problem, we are given a rod of length n inches and a table of prices <...
3votes
1answer
2kviews
Python program for "0-1 knapsack problem"
Here is what a knapsack/rucksack problem means (taken from Wikipedia): Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that ...
4votes
2answers
821views
Find the longest rectilinear path in a matrix with descending entries
Problem (Skiing): Each number represents the elevation of that area of the mountain. From each area (i.e. box) in the grid, you can go north, south, east, west - but only if the elevation ...